//
//  HMNoteCell.m
//  HeartMark
//
//  Created by rimi on 2016/11/8.
//  Copyright © 2016年 黄华强. All rights reserved.
//

#import "HMNoteCell.h"

@interface HMNoteCell ()
//内容文本框
@property (nonatomic,strong) UILabel *contentLabel;
//时间文本框
@property (nonatomic,strong) UILabel *timeLabel;
//显示是否公开的文本
@property (nonatomic,strong) UILabel *isPublicL;

@end


@implementation HMNoteCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setModel:(NoteModel *)model {
    _model = model;
    NSString *content = [_model.content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    _contentLabel.text = content;
    _timeLabel.text = _model.time;
   
    if ([_model.isPublic isEqualToString:@"YES"]) {
        _isPublicL.text = @"公开";
        [_isPublicL setTextColor:[UIColor redColor]];
    } else if ([_model.isPublic isEqualToString:@"NO"]) {
        _isPublicL.text = @"私有";
        [_isPublicL setTextColor:[UIColor blueColor]];
    }
}

- (void)setupUI {
    _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 8, SCREEN_WIDTH - 70, 36)];
    _contentLabel.font = [UIFont systemFontOfSize:13];
    _contentLabel.numberOfLines = 2;
    [self.contentView addSubview:_contentLabel];
    
    _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 52, SCREEN_WIDTH - 70, 15)];
    _timeLabel.font = [UIFont systemFontOfSize:11];
    _timeLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_timeLabel];
    
    _isPublicL = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 50, 8, 40, 28)];
    [self.contentView addSubview:_isPublicL];
}

@end
